package com.mrx.wallabagserver.controller;

import jakarta.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.web.servlet.error.ErrorAttributes;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Mr.X
 * @since 2024-03-15 09:30
 **/
@RestController
public class MyErrorController implements ErrorController {

    @Resource
    private ErrorAttributes errorAttributes;

    private static final Logger logger = LoggerFactory.getLogger(MyErrorController.class);

    @RequestMapping("/error")
    public ResponseEntity<?> onError() {
        logger.info("error: {}", errorAttributes);
        return ResponseEntity.badRequest().build();
    }

}
